<template>
  <div class="Tables">
    <el-table :data="tableData" border style="width: 100%">
      <el-table-column label="#" type="index" show-overflow-tooltip width="50" align="center"></el-table-column>
	  </el-table-column>
      <el-table-column prop="coupon_type" label="优惠类型" width="" align="center">
        <template slot-scope='scope'>
          <span>{{scope.row.coupon_type}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="coupon_money" label="优惠金额" width="" align="center">
        <template slot-scope='scope'>
          <span>{{scope.row.coupon_money}}元</span>
        </template>
      </el-table-column>
      <el-table-column prop="coupon_rule" label="订单价大于" width="" align="center">
        <template slot-scope='scope'>
          <span>{{scope.row.coupon_rule}}元</span>
        </template>
      </el-table-column>
      <el-table-column prop="coupon_start" label="开始时间" width="" align="center">
        <template slot-scope='scope'>
          <span>{{scope.row.coupon_start}}元</span>
        </template>
      </el-table-column>
      <el-table-column prop="coupon_end" label="结束时间" width="" align="center">
        <template slot-scope='scope'>
          <span>{{scope.row.coupon_end}}元</span>
        </template>
      </el-table-column>
      <el-table-column prop="status" label="状态" width="" align="center"></el-table-column>
    </el-table>
    <el-row>
      <el-col :span="24" class="pagination">
        <!-- 翻页 -->
        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pages.page"
          :page-sizes="[10, 20, 30]" background :page-size="10" layout="total, sizes, prev, pager, next" :total="pages.total">
        </el-pagination>
      </el-col>
    </el-row>
  </div>
</template>

<script>
  
  import {mapGetters} from 'vuex'
  export default {
    data() {
      return {
        //表格数据
        tableData: [],
        //页码数据
        pages: {},
      }
    },
    props: {
      //表格数据
      tabData: {
        type: Object,
        default: () => {
          return {}
        },
      },
    },
    computed: {
      ...mapGetters({
        permissions: 'user/permissions',
      }),
      ishowedit() {
        if (this.permissions[0] != 'admin') {
          return false
        } else {
          return true
        }
      }
    },
    methods: {
      //翻页总数
      handleSizeChange(val) {
        this.$emit('changepageTotal', val)
      },
      //翻页
      handleCurrentChange(val) {
        this.$emit('changepage', val)
      },
    },
    watch: {
      tabData(val) {
        this.tableData = val.list
        this.pages = val.page
      },
    },
    mounted() {
      this.tableData = this.tabData.list
      this.pages = this.tabData.page
    }
  }
</script>

<style scoped lang='scss'>
  .Tables {
    margin-top: 25px;
  }

  .edittext {
    margin: 0 10px;
    color: #4c68ef;
    cursor: pointer;
  }

  .pagination {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
  }
</style>
